//
//  LZXButton.m
//  自定义控件
//
//  Created by LZXuan on 14-8-17.
//  Copyright (c) 2014年 LZXuan. All rights reserved.
//

#import "LZXButton.h"
#import <MediaPlayer/MediaPlayer.h>
@interface LZXButton()
{
    ButtonEventBlock _btnBlock1;
    ButtonEventBlock _btnBlock2;
}

@property (nonatomic,copy)ButtonEventBlock btnBlock1;
@property (nonatomic,copy)ButtonEventBlock btnBlock2;
@end


@implementation LZXButton
- (void)dealloc {
    self.btnBlock2 = nil;
    self.btnBlock1 = nil;
    [super dealloc];
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)addClickEventTouchUpInside:(ButtonEventBlock)blocks{
    self.btnBlock1 = blocks;//先 释放之前 在copy
    [self addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
}
- (void)btnClick{
    if (self.btnBlock1) {
        self.btnBlock1(self);
    }
}

- (void)addClickEventTouchUpOutside:(ButtonEventBlock)blocks{
    self.btnBlock2 = blocks;
    [self addTarget:self action:@selector(btnClick2) forControlEvents:UIControlEventTouchUpOutside];
}
- (void)btnClick2{
    if (self.btnBlock2) {
        self.btnBlock2(self);
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
